﻿﻿using FileManager.Models;
using FileManager.Services;
using FileManager.ViewModels;
using System.Windows;

namespace FileManager
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            // 初始化DbContext
            var dbContext = new AppDbContext();
            
            // 设置视图模型
            var viewModel = new MainViewModel
            {
                // 初始化服务实例
                DbContext = dbContext,
                FileScanner = new FileScanner(dbContext),
                FileManagerService = new FileManagerService(dbContext),
                DuplicateFileFinder = new DuplicateFileFinder(dbContext),
                DatFileDecryptor = new DatFileDecryptor(),
                DatabaseBackupService = new DatabaseBackupService(),
                Settings = new AppSettings()
            };
            
            // 初始化视图模型数据
            viewModel.Initialize();
            
            // 设置数据上下文
            DataContext = viewModel;
        }
    }
}